#include "cli.h" 
#include "basic.h"
#include "cli_func.h"
#include "colorful.h"
#include <cstdio>
#include <cstring>
#include <iostream>
#include <ctime>
#include <cstdlib>

void cout_time() {
    // 基于当前系统的当前日期/时间
    time_t now = time(0);

    // 把 now 转换为字符串形式
    char* dt = ctime(&now);
    std::cout<< dt ;
}

int grammar_cli(char letter[]) {
    int strl = std::strlen(letter);
    int i1 = 0, i2 = 0;//i1判断括号
    while (letter[i1] != '(')++i1;//找到位置
    char message[1000];
    for (int i = 0; i <= std::strlen(letter); i++)message[i] = 0;
    for (int j = 0; j < i1; j++) {//将字符串提取
        message[j] = letter[j];
    }
    if (endwith_yr_cli(letter))return 1;
    return 0;
}

bool endwith_yr_cli(char letter[]) {
    int strl = std::strlen(letter);
    if ((!(letter[strl - 1] == 'r' && letter[strl - 2] == 'y' && letter[strl - 3] == ' ')) && (sentence_type(letter) == 1)) {
        std::cout << "In line %d Should end with yr\n";
        return 1;
    }
    else {
        return 0;
    }
}

void geng_picture(){
    srand(time(NULL));
    int t=rand()%4;
    switch (t){
    case 0:
        printf("\n");
        printf("       @                                \n");
        printf("        @      @@                         \n");
        printf("         @    @       @                        \n");
        printf("         @  @          @                     \n");
        printf("         @@             @ @ @                \n");
        printf("         @              @     @            \n");
        printf("        @              @                 \n");
        printf("       @              @                 \n");
        // std::cout<<HIDE<<"zhii"<<NONE<<std::endl;
        break;
    case 1:
        printf("           zhii                \n");
        printf("      ___checken              zhii\n");
        printf("    /   @      \\       _--_checken\n");
        printf("   /  /  @    @@      /    @     \\\n");
        printf("  /  /|   @  @  \\    /  /|   @     \\\n");
        printf("  \\  \\|   @@     \\   \\  \\|   @ @ @  \\\n");
        printf("   \\ ____ @    __/    \\ ____ @    _@/\n");
        printf("    /    @    \\        /    @    \\\n");
        printf("   /    @     \\       /    @     |\n");
        // std::cout<<HIDE<<"           zhii                \n";
        // std::cout<<"      ___checken              zhii\n";
        // std::cout<<"    /   "<<NONE<<"@      "<<HIDE<<"\\       _--_checken\n";
        // std::cout<<"   /  /  "<<NONE<<"@    @@      "<<HIDE<<"/"<<NONE<<"    @     "<<HIDE<<"\\\n";
        // std::cout<<"  /  /|   "<<NONE<<"@  @  "<<HIDE<<"\\    /  /|   "<<NONE<<"@"<<HIDE<<"     \\\n";
        // std::cout<<"  \\  \\|   "<<NONE<<"@@"<<HIDE<<"     \\   \\  \\|   "<<NONE<<"@ @ @"<<HIDE<<"  \\\n";
        // std::cout<<"   \\ ____ "<<NONE<<"@"<<HIDE<<"    __/    \\ ____ "<<NONE<<"@    "<<HIDE<<"_"<<NONE<<"@"<<HIDE<<"/\n";
        // std::cout<<"    /    "<<NONE<<"@   "<<HIDE<<"\\         /    "<<NONE<<"@"<<HIDE<<"   \\\n";
        // std::cout<<"   /    "<<NONE<<"@"<<HIDE<<"    \\        /    "<<NONE<<"@"<<HIDE<<"    |\n"<<NONE;
    break;
    case 2:
        printf("           #\n");
        printf("         #  #    #\n");
        printf("        #   #    # ####\n");
        printf("           #     ##    #\n");
        printf("            ## ###      #\n");
        printf("              #  #\n");
        printf("             #   #\n");
        printf("            #    #\n");
        printf("             ####\n");
    break;
    case 3:
        printf("                --11451419180--\n");
        printf("              /   \\     /    /\n");
        printf("             /     \\  /      /\n");
        printf("            /       |       /\n");
        printf("           /    /  /  \\    /\n");
        printf("          /      ----     /\n");
        printf("         |     /   /     /\n");
        printf("         |     ----     /\n");
        printf("       -----------------tsh2\n");
    default:
        break;
    }
}

/**
printf("           zhii                \n");
printf("      ___checken              zhii\n");
printf("    /   @      \       _--_checken\n");
printf("   /  /  @    @@      /    @     \\n");
printf("  /  /|   @  @  \    /  /|   @     \\n");
printf("  \  \|   @@     \   \  \|   @ @ @  \\n");
printf("   \ ____ @    __/    \ ____ @    _@/\n");
printf("    /    @    \        /    @    \\n");
printf("   /    @     \       /    @     |\n");
 */

/**
printf("           #\n");
printf("         #  #    #\n");
printf("        #   #    # ####\n");
printf("           #     ##    #\n");
printf("            ## ###      #\n");
printf("              #  #\n");
printf("             #   #\n");
printf("            #    #\n");
printf("             ####\n");
 */

/**
printf("                --11451419180--\n");
printf("              /   \     /    /\n");
printf("             /     \  /      /\n");
printf("            /       |       /\n");
printf("           /    /  /  \    /\n");
printf("          /      ----     /\n");
printf("         |     /   /     /\n");
printf("         |     ----     /\n");
printf("       -----------------tsh2\n");
 */